var express = require('express');
var usersRouter = require('./routes/users');
var sfjRouter = require('./routes/calligraphist');
var propertyRouter = require('./routes/property');
var styleRouter = require('./routes/style');
var eventRouter = require('./routes/event');
var materialRouter = require('./routes/material');
var styleRouter = require('./routes/style');
var eventRouter = require('./routes/event');
var articleRouter = require('./routes/article');
var commentRouter = require('./routes/comment');
const {
  sequelize
} = require('./db/index');
const cors= require('cors')

var app = express();
app.use(express.json())
app.use(cors())
app.use('/user', usersRouter);
app.use('/sfj', sfjRouter);
app.use('/property', propertyRouter);
app.use('/style', styleRouter);
app.use('/event', eventRouter);
app.use('/material', materialRouter);
app.use('/style', styleRouter);
app.use('/event', eventRouter);
app.use('/article', articleRouter);
app.use('/comment', commentRouter);

app.use(require('./routes/upload'))
app.use('/uploads', express.static(__dirname + '/uploads'))
app.use('/web', express.static(__dirname + '/web'))
// (async () => { //模型同步到数据库(ORM映射)
//   await sequelize.sync({
//     force: false
//   }) //force: true =>每次新建表
// })()



app.listen(3000); //koa自带服务器端口3000